<template>
  <div class="right_avarto">
    <div v-if="!isState">
      <h3>请选择</h3>
    </div>
    <div class="avarto_form" v-else>
      <el-form ref="form" :model="form">
        <el-form-item label="姓名">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <!-- <el-form-item label="居住地">
          <el-input v-model="form.address"></el-input>
        </el-form-item>
        <el-form-item label="职业">
          <el-input v-model="form.job"></el-input>
        </el-form-item>
        <el-form-item label="详细信息">
          <el-input type="textarea" v-model="form.content"></el-input>
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" @click="onSubmit">确定</el-button>
          <el-button @click="onClear">取消</el-button>
        </el-form-item>
      </el-form>
    </div>

    <!-- 正确内容显示区域 -->
    <!-- <div class="detials correct" v-else-if="!isError && !isdisabled">
            <div class="det_left">
                <div>
                    <h1>{{ imageData.name }}</h1>
                    <div class="sub_info">
                        <span>{{ imageData.nativePlace }}</span>
                        <el-divider direction="vertical"></el-divider>
                        <span>{{ imageData.occupation[0] }}</span>
                    </div>
                    <p class="detail_text">{{ imageData.detial }}</p>
                </div>
            </div>
            <div class="det_img">
                <img :src="imageData.image" alt="头像">
            </div>
        </div> -->

    <!-- 错误内容与正确内容上下排列显示区域 -->
    <!-- <div v-else-if="isError" class="comparison_container"> -->
    <!-- 错误内容显示区域 -->
    <!-- <div class="detials error">
                <div class="det_left">
                    <div>
                        <h1>{{ form.name }}</h1>
                        <div class="sub_info">
                            <span>{{ form.nativePlace }}</span>
                            <el-divider direction="vertical"></el-divider>
                            <span>{{ form.occupation[0] }}</span>
                        </div>
                        <p class="detail_text">{{ form.detial }}</p>
                    </div>
                </div>
                <div class="det_img">
                    <img :src="form.image" alt="用户输入的头像">
                </div>
            </div> -->

    <!-- 正确内容显示区域 -->
    <!-- <div class="detials correct">
                <div class="det_left">
                    <div>
                        <h1>{{ imageData.name }}</h1>
                        <div class="sub_info">
                            <span>{{ imageData.nativePlace }}</span>
                            <el-divider direction="vertical"></el-divider>
                            <span>{{ imageData.occupation[0] }}</span>
                        </div>
                        <p class="detail_text">{{ imageData.detial }}</p>
                    </div>
                </div>
                <div class="det_img">
                    <img :src="imageData.image" alt="正确的头像">
                </div>
            </div> -->
    <!-- </div> -->
  </div>
</template>

<script>
export default {
    props: ["isState", "popQuData","cardItem"],
    data() {
        return {
            form: {...this.popQuData},
            // isdisabled: true,
            // isError: true
        };
    },
    methods: {
        onSubmit() {

            // const params = { paperId: this.form.paperId, quId: this.form.quId, answers: answers, answer: this.saqValue }
            // fillPopAnswer()
            const params = { name: this.form.name, job: this.form.job, address:this.form.address, content:this.form.content }

            this.$emit("onSubmit", params);
            
        },
        onClear() {
            this.$emit("onState", false);
            // this.isdisabled = true;
            // this.isError = false;

        },
        isObjectChanged(source, comparison) {
            return (
                source.name == comparison.name &&
                source.nativePlace == comparison.nativePlace &&
                source.occupation[0] == comparison.occupation[0] &&
                source.detial == comparison.detial
            );
        }
    },
    watch: {
      cardItem:{
        handler(newVal){
          this.form = {
            
          }
        },
        deep:true
      }
        
    }
};
</script>

<style lang="scss" scoped>
.right_avarto {
  width: 50%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f6f4f4;

  .avarto_form {
    width: 60%;
    background-color: rgb(240, 240, 235);
    display: flex;
    justify-content: center;
    border-radius: 8px;
    padding: 20px;

    form {
      width: 90%;
    }
  }

  .comparison_container {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .detials {
    width: 95%;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    transition: all 0.3s ease;

    &.correct {
      background-color: #e6f7e6;
      border: 1px solid #67c23a;
    }

    &.error {
      background-color: #fde2e2;
      border: 1px solid #f56c6c;
    }

    .det_left {
      width: 60%;

      h1 {
        font-size: 26px;
        font-weight: bold;
        color: #333;
        margin-bottom: 8px;
      }

      .sub_info {
        display: flex;
        align-items: center;
        font-size: 16px;
        color: #777;

        span {
          margin: 0 5px;
        }

        .el-divider {
          margin: 0 10px;
          border-color: #ddd;
        }
      }

      .detail_text {
        margin-top: 15px;
        font-size: 14px;
        color: #555;
        line-height: 1.6;
        text-align: justify;
      }
    }

    .det_img {
      width: 30%;
      display: flex;
      justify-content: center;
      align-items: center;

      img {
        width: 100%;
        height: auto;
        border-radius: 12px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
        transition: transform 0.3s ease;
      }

      img:hover {
        transform: scale(1.05);
      }
    }
  }
}
</style>
